package com.song.oss.controller;

import com.song.commonutils.ResultObj;
import com.song.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author song
 * @data 2020/3/28
 */
@RestController
@RequestMapping("/eduoss/fileoss")
@Api(description = "文件上传")
@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

    /**
     * 上传头像
     * @param file
     * @return
     */
    @ApiOperation(value = "上传头像")
    @PostMapping("/uploadPic")
    public ResultObj  uploadFileAvatar(MultipartFile file){
        //返回上传到oss的路径
        String url=ossService.uploadFileAvatar(file);
        return ResultObj.ok().data("url",url);
    }
}
